package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	jsonBuf := `{"company":"ky","isOk":true,"price":55.4,"sub":["go","c++"]}`

	m := make(map[string]interface{}, 4)
	err := json.Unmarshal([]byte(jsonBuf), &m)
	if err != nil {
		fmt.Println("tmp = ", err)
		return
	}
	fmt.Printf("m = %+v\n", m)
	//类型断言
	for key, value := range m {
		switch data := value.(type) {
		case string:
			fmt.Printf("map[%s]的类型为string, value =  %v\n", key, data)
		case bool:
			fmt.Printf("map[%s]的类型为bool, value = %v \n", key, data)
		case float64:
			fmt.Printf("map[%s]的类型为float64,value = %v\n", key, data)
		case float32:
			fmt.Printf("map[%s]的类型为float32,value = %v\n", key, data)
		case []interface{}:
			fmt.Printf("map[%s]的类型为[]interface{},value = %v\n", key, data)
		}
	}
}
